package com.foogui.annotation;

import java.lang.reflect.Method;

public class Dog {
    @DogAnnotation(age = 2)
    public void study(int times){
        for(int i = 0; i < times; i++){
            System.out.println("Good Good Study, Day Day Up!");
        }
    }

    public static void main(String[] args) {
        Class<Dog> studentClass = Dog.class;
        try {
            Method study = studentClass.getDeclaredMethod("study", int.class);
            if (study.isAnnotationPresent(DogAnnotation.class)){
                DogAnnotation annotation = study.getAnnotation(DogAnnotation.class);
                System.out.println("名字是"+annotation.name()+"年龄是"+annotation.age());
            }
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }

    }
}
